<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/5/12
 * Time: 12:06
 */
include "MySqlConnect.php";
$mysqlconnect = new MySqlConnect();
$jieshou = $_REQUEST["jieshou"];
$openid = $_REQUEST["openid"];


if($jieshou=="yemian")
{
	date_default_timezone_set('PRC');
	$yemian = $_REQUEST["yemian"];$type = $_REQUEST["type"];$nowtime = date('Y-m-d H:i:s');
	$jieguo = $mysqlconnect->ExecuteData("insert into yemian values(null,'$openid','$yemian','$type','$nowtime')");
	echo $jieguo;
}
if($jieshou=="AddUser"){
	date_default_timezone_set('PRC');
//	$username = $_REQUEST["username"];
//	$headimg = $_REQUEST["headimg"];
//	$sex = $_REQUEST["sex"];
//	$city = $_REQUEST["city"];
	$nowtime = date('Y-m-d H:i:s');
	$mysqlconnect = new MySqlConnect();
	$querystr = "select * from users where openid='$openid'";
	$info =json_decode($mysqlconnect->GetDataSetJsonPHP($querystr)) ;
	$count = count($info);
//	echo  $count;
	if($count=="0")
	{
		try
		{
			$jieguo = $mysqlconnect->ExecuteData("insert into users values(null,'$openid','','','$nowtime','','','','','','')");
//			echo $jieguo;
		}
		catch(Exception $err){
//			echo $err;
		}

//		echo "qin".$jieguo;
	}
	else
	{
		echo $mysqlconnect->GetDataSetJsonPHP($querystr);
	}
	
	
}

if($jieshou=="tijiao"){
	date_default_timezone_set('PRC');
	$xingming = $_REQUEST["xingming"];
	$dianhua = $_REQUEST["dianhua"];
	$xingbie = $_REQUEST["xingbie"];
	$chengshi = $_REQUEST["chengshi"];
	$nowtime = date('Y-m-d H:i:s');
	$mysqlconnect = new MySqlConnect();
	try
	{
		$jieguo = $mysqlconnect->ExecuteData("update users set xingming='$xingming',dianhua='$dianhua',xingbie='$xingbie',chengshi='$chengshi',tjtime='$nowtime' where openid='$openid'");
		$jieguo1 = $mysqlconnect->ExecuteData("insert into info  values(null,'$openid','$xingming','$xingbie','$dianhua','$chengshi','$nowtime','')");
		echo $jieguo;
	}
	catch(Exception $err){
		echo $err;
	}
	
//	echo "1";
//	echo $mysqlconnect->GetDataSetJsonPHP($querystr);
}
if($jieshou=="getlist")
{
	echo $mysqlconnect->GetDataSetJson("select * from mingdan order by id desc");
	
}



?>
